import request from '@/utils/request'

// 封装调用获取频道的文章列表接口的函数
export const getArticles = params => request({
  method: 'GET',
  url: '/v1_0/articles',
  params
})

// 获取文章详情的
export const getArticleDetail = id => request({
  url: `/v1_0/articles/${id}`
  // timeout: 20
})

// 收藏文章
export const addCollect = id => request({
  method: 'POST',
  url: '/v1_0/article/collections',
  data: {
    target: id
  }
})

// 取消收藏
export const deleteCollect = id => request({
  method: 'DELETE',
  url: `/v1_0/article/collections/${id}`
})

// 封装利用id调点赞文章接口的函数
export const addLike = id => request({
  method: 'POST',
  url: '/v1_0/article/likings',
  data: {
    target: id
  }
})

// 封装利用id调取消文章点赞接口的函数
export const deleteLike = id => request({
  method: 'DELETE',
  url: `/v1_0/article/likings/${id}`
})
